<?php
/**
 * Routes configuration
 *
 * In this file, you set up routes to your controllers and their actions.
 * Routes are very important mechanism that allows you to freely connect
 * different urls to chosen controllers and their actions (functions).
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
	// Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

	Router::connect('/', array('controller' => 'Bookmakers', 'action' => 'index'));
	
	
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
 
 	Router::parseExtensions('xml'); 	
	Router::connect('/sitemap', array('controller' => 'Sitemaps', 'action' => 'index'));
	Router::connect('/sitemap_bookmaker', array('controller' => 'Sitemaps', 'action' => 'bookmaker'));
	Router::connect('/sitemap_odds', array('controller' => 'Sitemaps', 'action' => 'odds'));
	Router::connect('/sitemap_live', array('controller' => 'Sitemaps', 'action' => 'live'));
	Router::connect('/sitemap_livescore', array('controller' => 'Sitemaps', 'action' => 'livescore'));
	Router::connect('/sitemap_historical/:country', array('controller' => 'Sitemaps', 'action' => 'historical')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'pass' => array('country')
				    )
	);

	Router::connect('/Bookmaker/:name', array('controller' => 'Bookmakers', 'action' => 'detail')
					, array(
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name')
				    )
	);
	Router::connect('/bookmaker/:name', array('controller' => 'Bookmakers', 'action' => 'detail')
					, array(
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name')
				    )
	);
	
	
	Router::connect('/bookmaker/:name/payment-method/:metodo', array('controller' => 'Pagamento', 'action' => 'view')
					, array(
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'metodo' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name','metodo')
				    )
	);
	Router::connect('/bookmaker/:name/metodo-pagamento/:metodo', array('controller' => 'Pagamento', 'action' => 'view')
					, array(
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'metodo' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name','metodo')
				    )
	);
	
	Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

	Router::connect('/rest/chart/*', array('controller' => 'Chart', 'action' => 'index'));
	

	Router::connect('/matches', array('controller' => 'Match', 'action' => 'index'));

	Router::connect('/matches/:country', array('controller' => 'Match', 'action' => 'league')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'pass' => array('country')
				    )
	);

	Router::connect('/matches/:country/:league', array('controller' => 'Match', 'action' => 'season')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('country','league')
				    )
	);
	
	Router::connect('/matches/:country/:league/:season', array('controller' => 'Match', 'action' => 'team')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'pass' => array('country','league','season')
				    )
	);

	Router::connect('/matches/:country/:league/:season/:week', array('controller' => 'Match', 'action' => 'searchweek')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'week' => '[0-9]+',
				    'pass' => array('country','league','season','week')
				    )
	);
	
	Router::connect('/matches/:country/:league/:season/:team', array('controller' => 'Match', 'action' => 'search')
					, array(
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'team' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('country','league','season','team')
				    )
	);

	
	/* gestione url multilingua */
	
	Router::connect('/:lang', array('controller' => 'Bookmakers', 'action' => 'index'), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang', array('controller' => 'pages', 'action' => 'display', 'home'), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang/pages/*', array('controller' => 'pages', 'action' => 'display'), array('lang' => '[it,en]{2}'));

	Router::connect('/:lang/bookmaker/:name/payment-method/:metodo', array('controller' => 'Pagamento', 'action' => 'view')
					, array(
					'lang' => '[it,en]{2}',
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'metodo' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name','metodo')
				    )
	);
	Router::connect('/:lang/bookmaker/:name/metodo-pagamento/:metodo', array('controller' => 'Pagamento', 'action' => 'view')
					, array(
					'lang' => '[it,en]{2}',
				    'name' => '[a-zA-Z0-9\-\.]+',
				    'metodo' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('name','metodo')
				    )
	);
	Router::connect('/:lang/bookmaker/:name', array('controller' => 'Bookmakers', 'action' => 'detail')
					, array('lang' => '[it,en]{2}','name' => '[a-zA-Z0-9\-\.]+'
					,'pass' => array('name')));
					
	
	Router::connect('/:lang/odds/:country', array('controller' => 'Match', 'action' => 'odds_country')
					, array('lang' => '[it,en]{2}',
					'country' => '[a-zA-Z\-\.]+',
				    'pass' => array('country')
					)
	);
	Router::connect('/:lang/odds/:country/:match', array('controller' => 'Match', 'action' => 'odds_match')
					, array('lang' => '[it,en]{2}',
					'country' => '[a-zA-Z\-\.]+',
					'match' => '[0-9]+',
				    'pass' => array('country','match')
					)
	);
	Router::connect('/:lang/odds', array('controller' => 'Match', 'action' => 'odds'), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang/live/*', array('controller' => 'Match', 'action' => 'live'), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang/livescore/*', array('controller' => 'Match', 'action' => 'livescore'), array('lang' => '[it,en]{2}'));

	Router::connect('/:lang/stats/match/*', array('controller' => 'Stats', 'action' => 'match'), array('lang' => '[it,en]{2}'));

	Router::connect('/:lang/matches', array('controller' => 'Match', 'action' => 'index'), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang/matches/:country', array('controller' => 'Match', 'action' => 'league')
					, array(
					'lang' => '[it,en]{2}',
					'country' => '[a-zA-Z\-\.]+',
				    'pass' => array('country')
				    )
	);
	Router::connect('/:lang/matches/:country/:league', array('controller' => 'Match', 'action' => 'season')
					, array(
					'lang' => '[it,en]{2}',
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('country','league')
				    )
	);
	Router::connect('/:lang/matches/:country/:league/:season', array('controller' => 'Match', 'action' => 'team')
					, array(
					'lang' => '[it,en]{2}',
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'pass' => array('country','league','season')
				    )
	);
	Router::connect('/:lang/matches/:country/:league/:season/:week', array('controller' => 'Match', 'action' => 'searchweek')
					, array(
					'lang' => '[it,en]{2}',
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'week' => '[0-9]+',
				    'pass' => array('country','league','season','week')
				    )
	);
	Router::connect('/:lang/matches/:country/:league/:season/:team', array('controller' => 'Match', 'action' => 'search')
					, array(
					'lang' => '[it,en]{2}',
				    'country' => '[a-zA-Z\-\.]+',
				    'league' => '[a-zA-Z0-9\-\.]+',
				    'season' => '[0-9\-]+',
				    'team' => '[a-zA-Z0-9\-\.]+',
				    'pass' => array('country','league','season','team')
				    )
	);
		
	Router::connect('/:lang/:controller/*', array(), array('lang' => '[it,en]{2}'));
	Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[it,en]{2}'));
	
		
	/* ---------------------------------- */

/**
 * Load all plugin routes.  See the CakePlugin documentation on 
 * how to customize the loading of plugin routes.
 */
	CakePlugin::routes();

/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
	require CAKE . 'Config' . DS . 'routes.php';
